package com.njzxw.yoga.yogaApi.controller;

import com.njzxw.fs.commonutil.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import com.njzxw.yoga.yogaApi.server.ShopInfoServer;
import com.njzxw.yoga.yogaApi.bean.ShopInfoBean;
import com.njzxw.fs.commonutil.bean.BaseBean;
import org.springframework.validation.BindingResult;
import com.njzxw.fs.commonutil.web.ReturnMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("shopInfo")
public class ShopInfoController extends BaseController{

    @Autowired
    private ShopInfoServer shopInfoServer;

    /**
     * 分页获取数据
     */
    @RequestMapping("/queryPage")
    public ReturnMap queryPage(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({ShopInfoBean.QueryPage.class, BaseBean.CheckAuthority.class}) ShopInfoBean shopInfoBean, BindingResult bindingResult) {
        return shopInfoServer.queryPage(request,response,shopInfoBean);
    }

    /**
     * 获取但一条数据信息
     */
    @RequestMapping("/queryId")
    public ReturnMap queryId(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({ShopInfoBean.QueryId.class,BaseBean.CheckId.class, BaseBean.CheckAuthority.class}) ShopInfoBean shopInfoBean, BindingResult bindingResult) {
        return shopInfoServer.queryId(request,response,shopInfoBean);
    }

    /**
     * 修改某一条数据信息
     */
    @RequestMapping("/update")
    public ReturnMap update(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({ShopInfoBean.Update.class,BaseBean.CheckId.class, BaseBean.CheckAuthority.class}) ShopInfoBean shopInfoBean, BindingResult bindingResult) {
        return shopInfoServer.update(request,response,shopInfoBean);
    }

    /**
     * 删除数据信息
     */
    @RequestMapping("/delete")
    public ReturnMap delete(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({ShopInfoBean.Delete.class, BaseBean.CheckAuthority.class}) ShopInfoBean shopInfoBean, BindingResult bindingResult) {
        return shopInfoServer.delete(request,response,shopInfoBean);
    }

    /**
     * 插入数据信息
     */
    @RequestMapping("/insert")
    public ReturnMap insert(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({ShopInfoBean.Insert.class, BaseBean.CheckAuthority.class}) ShopInfoBean shopInfoBean, BindingResult bindingResult) {
        return shopInfoServer.insert(request,response,shopInfoBean);
    }

    /**
     * 插入数据信息
     */
    @RequestMapping("/save")
    public ReturnMap save(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({ShopInfoBean.Save.class, BaseBean.CheckAuthority.class}) ShopInfoBean shopInfoBean, BindingResult bindingResult) {
        return shopInfoServer.save(request,response,shopInfoBean);
    }

    /**
     * 导入方法
     * @param request
     * @param response
     */
    @RequestMapping("/import")
    public ReturnMap importShopInfo(HttpServletRequest request, HttpServletResponse response,@RequestBody  ShopInfoBean shopInfoBean){
        return shopInfoServer.importShopInfo(request,response,shopInfoBean);
    }

    /**
     * 根据用户权限获取不同组织门店信息
     */
    @RequestMapping("/getUserShop")
    public ReturnMap getUserShop(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({BaseBean.CheckAuthority.class}) BaseBean baseBean, BindingResult bindingResult) {
        return shopInfoServer.getUserShop(request,response,baseBean);
    }

}